$(function () {
    initPage();

     function initPage() {
         let Pr_item = new Promise( (resolve,reject)=>{
             $.ajax({
                 type: 'post',
                 url : '/projectDetails/get_excellent_works.do',
                 data : {},
                 dataType : 'json',
                 xhrFields : {
                     withCredentials: true
                 },
                 crossDomain: true,
                 success: function (data) {
                     if(data.status == 0){
                         resolve( data );
                     }else{
                         reject( data );
                     }
                 }
             });
         });

         let all_Pr = Promise.all( [Pr_item] );
         all_Pr.then( (data)=>{
            let itemList = data[0];
             To_item(itemList.data);
         }).catch( (data)=>{
             if(data.status == 10){
                 spop_waring(data.msg,()=>{},outLoing);
             }else{
                 spop_waring(data.msg);
             }
         } )
     }

     function To_item(aData) {
         aData.forEach( (item,idx)=>{
             let DOM = $('<li class="media">\n' +
                 '            <div class="media-left">\n' +
                 '                <a href="/look-item.html?projectno='+ item.projectno +'">' +
                 '                    <img class="media-object" style="width: 180px;height: 130px" src="'+ item.coverurl +'" >' +
                 '                </a>\n' +
                 '            </div>\n' +
                 '            <div class="media-body">\n' +
                 '                <a href="/look-item.html?projectno='+ item.projectno +'" class="media-heading"><h4 class="Text-cup">'+ item.projectname +'</h4></a>\n' +
                 '                <p>参赛团队： <span>'+ item.team +'</span></p>' +
                 '                <p>参赛学生： <span>'+ item.addprojectstuname +'</span></p>' +
                 '                <p>项目级别： <span>'+ item.projectgrade+'</span></p>' +
                 '            </div>\n' +
                 '        </li>');
             $('#YouXiu-list').append( DOM );
         } )
     }
});